extends MarginContainer


var text_content
var text_source
const Max_text_width = 380

func _ready() -> void:
	if text_source == 0:
		size_flags_horizontal = Control.SIZE_SHRINK_END
	else:
		size_flags_horizontal = Control.SIZE_SHRINK_BEGIN
	size_flags_vertical = Control.SIZE_SHRINK_END
	
	$Text_container/Text_label.text = text_content
	await resized
	custom_minimum_size.x = min(size.x, Max_text_width)
	
	if size.x > Max_text_width:
		$Text_container/Text_label.autowrap_mode = TextServer.AUTOWRAP_ARBITRARY
